/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.playground.core.repository.memory;

import com.playground.core.entity.LoggedPlayer;
import com.playground.core.repository.LoggedPlayerRepository;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Service;

/**
 *
 * @author Tiago Peres
 */
@Service("loggedPlayerRepository")
public class LoggedPlayerRepositoryImpl implements LoggedPlayerRepository {
    private static Map<Long, LoggedPlayer> loggedPlayers = new HashMap<Long, LoggedPlayer>();

    public LoggedPlayer save(LoggedPlayer loggedPlayer) {
        loggedPlayers.put(loggedPlayer.getId(), loggedPlayer);
        return loggedPlayer;
    }

    public LoggedPlayer findOne(long id) {
        return loggedPlayers.get(id);
    }

    public void delete(LoggedPlayer loggedPlayer) {
        loggedPlayers.remove(loggedPlayer.getId());
    }

    public void deleteAll() {
        loggedPlayers = new HashMap<Long, LoggedPlayer>();
    }
    
}
